﻿using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using System.Web;
namespace Ecreate.Data.Hibernate
{


        public class WebStorage : ISessionStorage 
        {
            /**//// <summary>
            /// 获得ISession 
            /// </summary>
            /// <returns>获得的ISession</returns>
            public ISession Get() 
            {
                return (ISession)HttpContext.Current.Items[Config.HttpSessionSourceItemName];
            }

            /**//// <summary>
            /// 保存ISession
            /// </summary>
            /// <param name="value">需要保存的ISession</param>
            public void Set(ISession value) 
            {
                if (value != null)
                {
                    HttpContext.Current.Items.Add(Config.HttpSessionSourceItemName, value);
                }
                else
                {
                    HttpContext.Current.Items.Remove(Config.HttpSessionSourceItemName);
                }
            }


        }
}
